# 设置测试用模拟网络服务器的CMake版本
cmake_minimum_required(VERSION 3.16)
project(ChatServerMock LANGUAGES CXX)

# 查找 Qt6 核心包
find_package(Qt6 6.5 REQUIRED)

# 查找所需的 Qt6 组件
find_package(Qt6 COMPONENTS Core REQUIRED)
find_package(Qt6 COMPONENTS Widgets REQUIRED)
find_package(Qt6 COMPONENTS Protobuf REQUIRED) # 引入Protobuf
find_package(Qt6 COMPONENTS HttpServer REQUIRED) # 引入Http
find_package(Qt6 COMPONENTS WebSockets REQUIRED) # 引入WebSockert

# 引入proto文件路径
file(GLOB PB_FILES "../ChatClient/proto/*.proto")

qt_standard_project_setup()

qt_add_executable(ChatServerMock
    WIN32 MACOSX_BUNDLE
    main.cpp
    widget.cpp
    widget.h
    widget.ui
    server.h
    server.cpp
)

# 引入proto文件路径
qt_add_protobuf(ChatServerMock PROTO_FILES ${PB_FILES})

target_link_libraries(ChatServerMock
    PRIVATE
        Qt::Core
        Qt::Widgets
        Qt6::Protobuf
        Qt6::HttpServer
        Qt6::WebSockets
)

include(GNUInstallDirs)

install(TARGETS ChatServerMock
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET ChatServerMock
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
